// pages/help/writeRemark/writeRemark.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    helpId:0,
    userId:wx.getStorageSync('userId'),
    createBy:wx.getStorageSync('username'),
    status:0,
    title:"",
    content:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      helpId:options.id
    })
  },
  //检测富文本编辑器输入内容
  onInputtingDesc: function (e) {
    let html = e.detail.html;   //相关的html代码
    this.setData({
      content: html,
    });
  },
  //检测输入标题
  onInputTitle: function (e) {
    this.setData({
      title: e.detail.value,
    });
  },
  //提交求助内容
  onTapButton:function(){
    if(this.data.title==""){
      wx.showToast({title: '请输入求助标题',icon: 'none',duration: 1000})
    }else if(this.data.content==""){
      wx.showToast({title: '请输入求助内容',icon: 'none',duration: 1000})
    }else{
      app.$http.post('/app/help/add',this.data).then(resp=>{
        wx.navigateTo({
          url: '/pages/index/helpList/helpList?userId=0',
        })
      }).catch(err=>{
        console.log(err)
      })
    }
  }
})